import 'dart:convert';

import 'package:azlistview/azlistview.dart';

class CityModel extends ISuspensionBean {
  String name;
  String code;
  String nameEn;
  int id;
  String? tagIndex;
  String? namePinyin;
  bool select = false;

  CityModel({
    required this.name,
    required this.code,
    required this.nameEn,
    required this.id,
    this.tagIndex,
    this.namePinyin,
    required this.select,
  });

  CityModel.fromJson(Map<String, dynamic> json, {this.isHot = false, this.isChina = false})
      : name = json['name'],
        code = json['code'],
        nameEn = json['nameEn'],
        id = json['id'],
        tagIndex = json['tagIndex'],
        namePinyin = json['namePinyin'],
        select = json['select'] ?? false;

  Map<String, dynamic> toJson() => {
        'name': name,
        'code': code,
        'nameEn': nameEn,
        'id': id,
        // 'tagIndex': tagIndex,
        // 'namePinyin': namePinyin,
        // 'select': select,
      };

  /// 是否热门城市
  bool isHot = false;

  /// 是否是中国
  bool isChina = false;
  String get tag {
    if (isHot) {
      return 'Hot';
    } else if (isChina) {
      return '#';
    } else {
      return tagIndex!;
    }
  }

  @override
  String getSuspensionTag() {
    return tag;
  }

  @override
  String toString() => json.encode(this);
}
